One solution I've been tossing around is to detect this situation, and explicitly release all the pens on the screen when the program starts.
I'm also considering whether to set up a custom palette on screens, with an even spread of colors, so that most images will come out pretty well. Currently, the first image you view may use all your colors, and look great. However, subsequent images may not get a good match from those colors, and look worse.